{include file="public/header"/}
<link rel="stylesheet" href="{__PUBLIC_PATH}/admin/pcf/pcfbase1.css?v={$version}"/>
</head>
<body>
<div class="layui-fluid layui-form">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-sm12">
            <div class="layui-card" style="padding:15px;">
                    <div class="layui-card-body">
                        <div class="layui-form-item">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-inline wauto">
                                <input type="radio" name="status" value="1" title="启用" {if $rs.status} checked{/if}/>
                                <input type="radio" name="status" value="0" title="禁用" {if !$rs.status} checked{/if}/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">地址</label>
                            <div class="layui-input-inline wauto">
                                <input type="text" id="server" name="server" class="layui-input" value="{$rs.server}"/>
                            </div>
                            <div class="layui-form-mid">设置升级服务器地址信息</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">授权码</label>
                            <div class="layui-input-inline">
                                <input type="text" id="onlyid" name="onlyid" class="layui-input" value="{$rs.onlyid}"/>
                            </div>
                        </div> 
                        <div class="layui-form-item" style="display:none;">
                            <label class="layui-form-label">IP</label>
                            <div class="layui-input-inline">
                                <input type="text" name="ip" class="layui-input" value="{$rs.ip}"/>
                            </div>
                            <div class="layui-form-mid">如远程访问获取失败，可以在这里设置远程IP</div>
                        </div>
                        <div class="layui-form-item" style="display:none;">
                            <label class="layui-form-label">检测周期</label>
                            <div class="layui-input-inline">
                                <input type="text" id="date" name="date" class="layui-input" value="{$rs.date}"/>
                            </div>
                            <div class="layui-form-mid">单位：天，设为0不检测</div>
                        </div> 
                    </div>
            </div>
        </div>
    </div>
<div class="submit-info text-center">
	<button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
	<button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
</div>	
</div>

{include file="public/footer"/}
<script>
    layui.use(['layer', 'form'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        form.render();
        // 监听开关
        form.on('switch', function(data){
          var elemId = data.elem.attributes['lay-filter']['nodeValue'];
          if (data.elem.checked) {
            this.value = 1;
          } else {
            this.value = 0;
          }
          $("input[name='"+elemId+"']").val(this.value);
        });
		
        //监听提交
        form.on('submit(formSubmit)', function(data){
            layer.msg('正在处理请勿刷新页面', {icon: 16,shade: 0.01,time:3600000});
            $.ajax({
                type : 'post',
                url : "{:url('/update/set')}",
                data : data.field,
                dataType : 'json',
                success : function(res){
                    layer.closeAll();
                    if(res.status){
                        layer.msg(res.msg, {icon:1,time:1000}, function(){
                            parent.window.location.href = res.url;
                        });
                    }else{
                        layer.msg(res.msg, {icon: 2, time: 1000});
                    }
                },
                error: function(e){
                    layer.closeAll();
                    layer.msg("未知错误，操作中断！", {icon: 2, time: 1000});
                }
            });
            return false;
        });
		
		
    });
</script>
</body>
</html>